{header}
<script language="JavaScript" src="js/common.js"></script>

<table width="100%"  border="0" cellpadding="3" cellspacing="1" class="tableOutborder">
<tr class="tableHeader">
  <td colspan="9">添加产品</td>
</tr>
</table>

<form name="form1" id="form1" method="POST" action="products.php?action=add">
<table width="100%"  border="0" cellspacing="1" cellpadding="3" class="tableOutborder">
  <tr class="bg_0">
    <td width="8%" align="right">产品名称</td><td>
      <input type="hidden" name="id" id="id" value="{id}">
      <input type="text" name="pname" size="40" id="pname" value="{names}"  ></td>
  </tr>
  <tr><a href="javascript:history.back()"><span style="color:red">返回</span></a> </tr>
  <tr class="bg_0">
    <td  align="right">产品分类</td><td>{selecttreelist}</td>
  </tr>
  <tr class="bg_0">
    <td  align="right">首页显示</td><td><input type="checkbox" value="1" <!-- IF top=="1" -->checked<!-- ENDIF --> name="indextop" id="indextop"></td>
  </tr>
  <tr class="bg_0">
    <td  align="right">排序</td><td>
      <select id="sort" name="sort">
          <option value="">默认</option>
          <option value="1" <!-- IF sort=="1" -->selected<!-- ENDIF -->>置顶</option>
      </select>*默认为常规排序,新加的商品位于置顶商品之后第一位显示
    </td>
  </tr>
  <tr class="bg_0">
    <td  align="right">产品图片</td><td><span id="imgbox"><img src='{img_th}'></span>
      <input type="button" value="选择图片" onclick="javascirpt:window.open('imageDb.php?action=view');">
      <input type="hidden" name="imgid" id="imgid" value="{img_id}"> </td>
  </tr>
  <tr class="bg_0">
    <td  align="right">产品描述</td><td><textarea rows="15" cols="100" id='pdesc' name="pdesc">{desc}</textarea></td>
  </tr>
  <tr class="bg_1">
      <td  align="right"> </td><td colspan="2" valign="left">
      <input type="button" name="Submit" value=" 提交 " onclick="checkinput()" accesskey="s">
      <input name="reset" type="reset" id="reset" value=" 重置 "></td>
      </td>
  </tr>
</table>
</form>
<script type="text/javascript">
    function checkinput(){
        var pname=$("#pname").val();
        var imgurl=$("#imgurl").val();
        var catetree=$("#catetree").val();
        if(pname==""){alert("请输入产品名称");$("#pname").focus();return false;}
        if(catetree==""){alert("请选择产品分类");$("#catetree").focus();return false;}
        if(imgurl==""){alert("请选择产品图片");$("#imgurl").focus();return false;}
        $("#form1").submit();
    }
    function _callback_selectimg(id,imgurl){//供选择的回调函数
        if(id=="" || imgurl==""){
            alert("选取产品图片是发生错误,请重新选择或者刷新页面再操作！");
            return false;
        }else{
            var idarr=id.split("|");
            var imgurlarr=imgurl.split("|");
            if(idarr.length!=imgurlarr.length){
                alert("选择图片是时ID数与图片数不一致,请重新选择或者刷新页面后在操作");
                return false;
            }else if(idarr.length>2){
                alert("只能选择一张图片");
                return false;
            }else{
                var imghtml='';
                for(var i=0;i<imgurlarr.length;i++){
                    if(imgurlarr[i]!=""){
                        imghtml+="<img src='"+imgurlarr[i]+"'>";
                    }
                }
                $("#imgid").val(id);
                $("#imgurl").val(imgurl);
                $("#imgbox").html(imghtml);
            }
        }
    }
    $(function(){
        var cate={cate};
        $("#catetree").val(cate);
    })
</script>
{footer}
